package com.hl.sfzy.controller;

import com.hl.sfzy.constant.CommonConstant;
import com.hl.sfzy.constant.Result;

import com.hl.sfzy.entity.SysBooking;

import com.hl.sfzy.entity.SysEvaluate;
import com.hl.sfzy.entity.SysMessage;
import com.hl.sfzy.service.SysEvaluateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@RestController
public class SysEvaluateController {
    @Autowired
    private SysEvaluateService sysEvaluateService;

    @PostMapping("/evaluate")
    public Result add(@RequestBody SysEvaluate sysEvaluate) {
        int num = sysEvaluateService.add(sysEvaluate);
        return num > 0 ? Result.success() : Result.error();
    }

    @DeleteMapping("/evaluate/{id}")
    public Result remove(@PathVariable("id") Integer id) {
        int num = sysEvaluateService.remove(id);
        return num > 0 ? Result.success() : Result.error();
    }

    @DeleteMapping("/evaluate")
    public Result removeBatch(Integer[] ids) {
        int num = sysEvaluateService.removeBatch(ids);
        return num > 0 ? Result.success() : Result.error();
    }

    @PutMapping("/`evaluate`")
    public Result edit(@RequestBody SysEvaluate sysEvaluate) {
        int num = sysEvaluateService.edit(sysEvaluate);
        return num > 0 ? Result.success() : Result.error();
    }

    @GetMapping("/evaluate/page")
    public Result findPage(
            @RequestParam(value = CommonConstant.PAGE_NUM, required = false, defaultValue = CommonConstant.PAGE_NUM_DEFAULT) Integer pageNum,
            @RequestParam(value = CommonConstant.PAGE_SIZE, required = false, defaultValue = CommonConstant.PAGE_SIZE_DEFAULT) Integer pageSize,
            SysEvaluate sysEvaluate ) {

        Map<String, Object> map = sysEvaluateService.findPage(pageNum, pageSize, sysEvaluate);
        return Result.success(map);
    }
    @GetMapping("/evaluate")
    public Result findAll(SysEvaluate sysEvaluate){
        List<SysEvaluate> sysEvaluates = sysEvaluateService.find(sysEvaluate);
        return Result.success(sysEvaluates);
    }

    @GetMapping("/evaluate/{id}")
    public Result findById(@PathVariable("id") Integer id){
        SysEvaluate byId = sysEvaluateService.findById(id);
        return Result.success(byId);
    }

    @GetMapping("/evaluate/consult/{id}")
    public Result findByconsultId(@PathVariable("id") Integer id){
        List<SysEvaluate> sysEvaluates = sysEvaluateService.selectByconselorId(id);
        return Result.success(sysEvaluates);
    }

    @GetMapping("/evaluate/limit/{id}")
    public Result findLimit(@PathVariable("id") Integer id){
        List<SysEvaluate> list = sysEvaluateService.selectLimit(id);
        return Result.success(list);
    }

    @GetMapping("/evaluate/order/{status}")
    public Result findByStatus(@PathVariable("status") Integer status){
        List<SysEvaluate> sysEvaluates = sysEvaluateService.findbyStatus(status);
        return Result.success(sysEvaluates);
    }

}
